package com.yanzhu.service.mapper;

import com.yanzhu.service.model.Recharge;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: 方炎柱
 * @Description:
 * @Date: Created in 21:48 2018/1/21
 * @Modified:
 */
@Mapper
public interface RechargeMapper {
    @Insert("insert into recharge(uid, recharge_fee, recharge_time) values(#{uid}, #{recharge_fee}, #{recharge_time})")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = long.class)
    int insert(Recharge recharge);

    @Select("select * from recharge" +
            " where uid = #{uid}" +
            " order by recharge_time desc" +
            " limit #{page}, ${size}")
    List<Recharge> queryRechargeList(@Param("uid") long uid, @Param("page") int page, @Param("size") int size);

    @Delete("delete from recharge where id = #{id}")
    int deleteRechargeById(@Param("id") long id);

    @Delete("delete from recharge where uid=#{uid}")
    int deleteRechargeAll(@Param("uid") long uid);
}
